Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

195
Vistas
Normalization and Denormalization MongoDB | Schema Question Follow System

I'm breaking my head over this:

The User on my WebApp can follow a Tag (Like a user can follow a subreddit), the followed Tag will be shown in the Homepage with a different color than the not followed one. If a User follows a Tag he will get Push-Notifications when a new Blog Post is published tagged with the Tag.

So I have to query for all the tags a given user follows.

And I have to query for all the user which follow a given tag.

A user can follow max 20 Tags. Since I have a Many to Many relation should i go with something like this (normalization)

const SubscribeToTagSchema = new Mongoose.Schema({
 user: {
  type: Schema.Types.ObjectId,
  ref: "User",
  required: true,
 },
 tag: {
  type: Schema.Types.ObjectId,
  ref: "Tag",
  required: true,
 },
});

or should I just save the data in both schema User and Tag?

const UserSchema = new Mongoose.Schema({
 tag: {
  type: Schema.Types.ObjectId,
  ref: "Tag",
  required: true,
 },
});

const TagSchema = new Mongoose.Schema({
 user: {
  type: Schema.Types.ObjectId,
  ref: "User",
  required: true,
 },
});
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda